--------------------------------------------------
-- Payolution Javascript Installment Calculator --
--------------------------------------------------

We recommend using the installment calculator in the following way:

- Getting the code by setting up a recurring job to download the latest script from our system
- Referencing your copy from your web site

Alternatively it is of course also possible to reference it directly, but we usually do
not recommend this option, as it has some major shortcomings including increased traffic
on our side and unnecessarily tight coupling between the merchant system and ours.

______________________________________
Getting the latest code
--------------------------------------

To get the latest version of the javascript library, just do a HTTP GET request to the following URL:

"https://payment.payolution.com/payolution-payment/infoport/installments/generatejs?id=CHANNEL_ID"

The CHANNEL_ID part of the text needs to be replaced by the channel code
that will be provided by payolution.

The library is already customized for you, so it includes the correct minimum and maximum amount, interest rate, etc..
But more on that later.

For testing purposes, the following URL can be used:
"https://test-payment.payolution.com/payolution-payment/infoport/installments/generatejs?id=test-installment"
Here a minimum of 150 and a maximum of 5000 are set.


Of course you can always try the GET request by opening an internet browser and typing the URL.


______________________________________
Referencing it on your website
--------------------------------------

direct reference example:
<script type="text/javascript" src="https://payment.payolution.com/payolution-payment/infoport/installments/generatejs?id=CHANNEL_ID"></script>

Note that we really recommend you to download the script once a day and put it on your
own server. This way your page is more independent from our system. And of course it 
also reduces the load of our servers a lot.

______________________________________
Usage
--------------------------------------

There are three informative functions:
Payolution.getMinimumAmount() - returns the minimum amount for installment payments
Payolution.getMaximumAmount() - returns the maximum amount for installment payments
Payolution.getAvailableDurations() - returns an array of possible durations

And two calculation function:
Payolution.calculateInstallment(amount,duration)
Payolution.calculateInstallmentFixedCurrency(amount, duration, currency)

By calling these functions and providing the original amount to be paid
and the number of months in which the payment will be split, the installment details
will be calculated.

It returns an object with the following values:
"installmentAmount" the amount of one installment
"interestRate" the nominal interestRate per year
"effectiveInterest" the effective interest rate per year
"totalAmount" the total amount the customer has to pay including interest and fees
"installments" an array of installment details, where each installment is again an object with both a "dueDate" and an "amount".


example usage to create a function that would return the monthly installment for a twelve month plan:

function getTwelveMonthPlan(amount) {
  response = Payolution.calculateInstallment(amount,12);
  return response.installmentAmount;
}

The method 'calculateInstallmentFixedCurrency' uses a fixed currency and provides additional features, like currency relevant rounding. For CHF it is e.g. usual to have 0.05 CHF denomination. By using the calculateInstallmentFixedCurrency method you can make sure these effects are taken into account.




